<template>
  <div>
    <el-table ref="table" :data="result.data" v-loading="loading"
              element-loading-text="拼命加载中"
              element-loading-spinner="el-icon-loading"
              element-loading-background="rgba(0, 0, 0, 0.8)">
      <el-table-column prop="id" label="ID">
      </el-table-column>
      <el-table-column prop="name" label="名称">
      </el-table-column>
      <el-table-column prop="no" label="编号">
      </el-table-column>
      <el-table-column prop="marketPrice" label="市场价">
      </el-table-column>
      <el-table-column prop="price" label="当前价格">
      </el-table-column>
      <el-table-column prop="description" label="描述">
      </el-table-column>
      <el-table-column prop="enabled" label="上架">
      </el-table-column>
      <el-table-column prop="hits" label="点击率">
      </el-table-column>
      <el-table-column prop="cdt" label="录入时间" :formatter="cdtFormatter">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  import utils from "@/bianmaba-exteneds/modules/utils"
  import {Table} from "element-ui"

  import Focus from 'element-ui/src/mixins/focus';

  export default {
    mixins: [Focus('table')],
    name: "BmbTable",
    components: {Table},
    data() {
      return {
        loading: true,
        result: {}
      };
    },
    methods: {
      handlePageSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentPageChange(val) {
        console.log(`当前页: ${val}`);
      },
      cdtFormatter: function (row, col, value) {
        return utils.dateFormat(value, "yyyy/MM/dd");
      }
    },
    mounted() {
      let params = {pageable: {page: 0, size: 2}};
      this.ajax.post("/management/product/query", params).then(resp => {
        if (resp && resp.data && resp.data.success == true) {
          this.result = resp.data;
          this.loading = false;
          console.log(this.result)
        }
      })
    }
  }
</script>
